package com.second.app.thread.线程基础.day04.dirtyread;

/**
 * @Author GYZ
 * @Date 2023/11/22
 * <pre>
 *
 * </pre>
 */
public class PublicVariable {
    public String userName = "A";

    public String password="AA";

    synchronized public void setValue(String userName,String password){
        try {
            this.userName =userName;
            Thread.sleep(5000);
            this.password =password;
            System.out.println("setValue method thread name="+Thread.currentThread().getName()+" userName="+userName+" password="+password);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    synchronized public void getValue(){
        System.out.println("getValue method thread name="+Thread.currentThread().getName()+" userName="+userName+" password="+password);
    }
}
